<?php
require_once("./DButil.php");

$powerId=$_REQUEST["id"];
$powerName=$_REQUEST["powerName"];

$sql = "select * from t_power where powerName='{$powerName}'";
if (query($sql)) {
    $result = [
        "msg" => "用户名重复",
        "code" => 400,
        "success" => false
    ];
}else{
    $sql1 = "update t_power set powerName='{$powerName}' where powerId={$powerId}";
    if (update($sql1)) {
        $result = [
            "msg" => "修改成功",
            "code" => 200,
            "success" => true
        ];
    }else{
        $result = [
            "msg" => "修改失败",
            "code" => 400,
            "success" => false
        ];
    }
}

header("Content-Type:application/json;charset=utf-8");
echo json_encode($result);

?>